/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package za.ac.cput.NullnessTest;



import java.lang.ref.WeakReference;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
import java.util.*;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import za.ac.cput.Nullness.Impl.MemoryLeakImpl;
import za.ac.cput.Nullness.MemoryLeak;
import za.ac.cput.Nullness.conf.AppNullConf;

/**
 *
 * @author Leo
 */
public class testNullness {
    
   public static MemoryLeak memoL;
   public static ApplicationContext ctx6;
   
    
    public testNullness() {
    }

    @BeforeClass
    public static void setUpClass() throws Exception {
        ctx6 =  new AnnotationConfigApplicationContext(AppNullConf.class);
        memoL = ctx6.getBean(MemoryLeak.class);
    }

    @AfterClass
    public static void tearDownClass() throws Exception {
    }
    
    @Before
    public void setUp() {
    }
    
    @After
    public void tearDown() {
    }
    // TODO add test methods here.
    // The methods must be annotated with annotation @Test. For example:
    //
     @Test
     public void testMemoryLeak() throws InterruptedException {
         
     MemoryLeak m1 = new MemoryLeakImpl(2,0);
     
     WeakReference ref = new WeakReference(m1);
     m1 = null;
     System.gc();
     System.gc();
     System.gc();
   
     assertNull(ref.get());
     }
}
